
#include "net.h"


static pthread_t  net_thread;


void* net_task(void *arg)
{
	static int flag = 0;
	struct timeval timer;	

	long start_time  = 0;
	long end_time    = 0;

	while(1)
	{
		usleep(1000);
		//************************************************************************

		timer.tv_sec  = 1;
		timer.tv_usec = 0;

		switch(select(0, NULL, NULL, NULL, &timer)) {
		case -1:  
			log_e("Error!\n");
			break;
		case 0: 
			break;
		default:break;
		}
		//************************************************************************
#if 1
		//log_i("******************************************************\n");
		net_sunning_servr_time();
		//log_i("******************************************************\n");
		if(!flag){
			flag = 1;

			start_time = platform_get_microsecond();
			//net_http_download("https://xz.ku138.cc/piccc/2023/zip/230122/967016743913392719.zip","./output/test.zip",30);
			//net_multi_download("https://xz.ku138.cc/piccc/2023/zip/230122/967016743913392719.zip","./output/test.zip");
			net_socket_download("https://xz.ku138.cc/piccc/2023/zip/230122/967016743913392719.zip","./output/test.zip");

			end_time = platform_get_microsecond();	
			log_i("time:%ld ms\n",(end_time - start_time)/1000);
		}

	
		//log_i("******************************************************\n");
#endif
		//************************************************************************


	}

}




int net_init(void)
{
	int ret = -1;
	log_i("net init.\n");


	ret=pthread_create(&net_thread, NULL, net_task, NULL);
	if(ret != 0){
		log_e("thread error=%s\n",strerror(ret));
	}



	return 0;
}


int net_deinit(void)
{
	log_i("net exit.\n");






	return 0;
}



